#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class App {
	int cnt = 1;
	vector<int> head, next, to;

	int power;
	vector<int> deep, parent;
	vector<long long> node;
	vector<vector<int>> stjump;

	int log2(int n)
	{
		int ans = 0;
		while ((1 << ans) <= (n >> 1)) {
			ans++;
		}
		return ans;
	}

	void addedge(int u, int v)
	{
		next[cnt] = head[u];
		to[cnt] = v;
		head[u] = cnt++;
	}

	void build(int n)
	{
		for (int i = 0, u, v; i < n - 1; i++) {
			cin >> u >> v;
			addedge(u, v);
			addedge(v, u);
		}
	}

	void dfs(int u, int p)
	{
		deep[u] = deep[p] + 1;
		parent[u] = p;
		stjump[u][0] = p;
		for (int z = 1; z <= power; z++) {
			stjump[u][z] = stjump[stjump[u][z - 1]][z - 1];
		}
		for (int e = head[u], v = to[e]; e; e = next[e], v = to[e]) {
			if (v != p) {
				dfs(v, u);
			}
		}
	}

	int lca(int u, int v)
	{
		if (deep[u] < deep[v]) {
			swap(u, v);
		}

		int k = deep[u] - deep[v];
		for (int p = log2(k); p >= 0; p--) {
			if (deep[stjump[u][p]] >= deep[v]) {
				u = stjump[u][p];
			}
		}
		if (u == v) {
			return u;
		}

		k = deep[v];
		for (int p = log2(k); p >= 0; p--) {
			if (stjump[u][p] != stjump[v][p]) {
				u = stjump[u][p];
				v = stjump[v][p];
			}
		}
		return stjump[u][0];
	}

	void dfs2(int u, int p)
	{
		for (int e = head[u], v = to[e]; e; e = next[e], v = to[e]) {
			if (v != p) {
				dfs2(v, u);
				node[u] += node[v];
			}
		}
	}

	long long cal_max()
	{
		dfs2(1, 0);
		return *max_element(node.begin(), node.end());
	}

    public:
	App(int n, int k)
		: power(log2(n)), head(n + 1, 0), next(n << 1, 0), to(n << 1, 0), deep(n + 1, 0), stjump(n + 1, vector<int>(power + 1, 0)), node(n + 1, 0), parent(n + 1, 0)
	{
		build(n);
		dfs(1, 0);
                int c, p, lcafather;
		for (int i = 0, u, v; i < k; i++) {
			cin >> u >> v;
			c = lca(u, v);
			node[u] += 1;
			node[v] += 1;
			node[c] -= 1;
                        p = parent[c];
			node[p] -= 1;
		}

		cout << cal_max() << endl;
	}
};

int main()
{
	int n, k;
	cin >> n >> k;
	App app(n, k);
	return 0;
}
